<template>
  <div class="exhibitions-container">
    <div class="exhibition">
      <h2>{{ currenttitle }}</h2>
      <h3>{{ currentenglish}}</h3>
      <router-view class="category-content" v-slot="{ Component, route }">
        <transition :name="`slide-${route.meta.direction}`" mode="out-in">
          <component 
            :is="Component"
            :key="route.path"
            :class="['content-wrapper', route.meta.bgColor]"
          />
        </transition>
      </router-view>
    </div>
    <footer class="footer">
      <p>© 2025 历史博物馆. 版权所有.</p>
      <button class="back-to-top" @click="scrollToTop">回到顶部</button>
    </footer>
  </div>
</template>

<script>
export default {
  name: 'Exhibition',
  data(){
    return{
      currenttitle: '',
      currentenglish:''
    };
  },
  methods: {
    scrollToTop() {
      window.scrollTo({
        top: 0,
        behavior: 'smooth'
      });
    },
    updateCategory() {
      // 从路由meta中获取分类名称，如果没有则使用默认值
      this.currenttitle = this.$route.meta.category;
      this.currentenglish=this.$route.meta.english;
    }
  },
  watch: {
    $route() {
      this.updateCategory();
    }
  },
  mounted() {
    this.updateCategory();
  }
};
</script>

<style scoped>
/* 背景层 */
.exhibitions-container::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('@/assets/background.jpg') repeat-x center/cover;
  z-index: -1;
  opacity: 0.3;
}

.exhibitions-container {
  position: relative;
  min-height: 100vh;
}

.exhibition {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(5px);
}

.exhibition h2{
  font-size: 30pt;
    color: #333;
    margin-bottom: 10px;
}

.exhibition h3{
    font-size: 12pt;
    color: gray;
    margin: 10px 0 40px;
    font-weight: normal;
}

.category-content {
  position: absolute;
  width: 100%;
}

.content-wrapper {
  padding: 40px 20px;
  min-height: 600px;
  border-radius: 12px;
}

/* 页面切换动画 */
.slide-left-enter-active,
.slide-left-leave-active,
.slide-right-enter-active,
.slide-right-leave-active {
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.slide-left-enter-from {
  transform: translateX(100%);
  opacity: 0;
}

.slide-left-leave-to {
  transform: translateX(-50%);
  opacity: 0;
}

.slide-right-enter-from {
  transform: translateX(-100%);
  opacity: 0;
}

.slide-right-leave-to {
  transform: translateX(50%);
  opacity: 0;
}
/* 底边栏 */
.footer {
  background: #333333;
  color: white;
  border-top: 2px solid #4D4D4D;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  box-sizing: border-box;
  backdrop-filter: blur(5px);
  width: 100%; /* 确保全宽 */
  margin-top: auto; /* 将footer推到页面底部 */
}
 
.back-to-top {
  padding: 8px 16px;
  background: #555555;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 14px;
  min-width: 100px;
}
 
.back-to-top:hover {
  background: #666666;
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .footer {
    flex-wrap: wrap;
    padding: 12px 10px;
    gap: 10px;
  }
  
  .back-to-top {
    min-width: auto;
    width: calc(50% - 10px);
  }
}
</style>
